//
//  MOViewController.m
//  MOPush
//
//  Created by Alfie on 03/31/2021.
//  Copyright (c) 2021 Alfie. All rights reserved.
//

#import "MOViewController.h"
#import <MOPush/MOPushClient.h>

@interface MOViewController ()

@end

@implementation MOViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    UIButton *setAliasBtn = [[UIButton alloc] initWithFrame:(CGRectMake((UIScreen.mainScreen.bounds.size.width - 200)/2, 100, 200, 50))];
    [setAliasBtn addTarget:self action:@selector(setAliasAction) forControlEvents:(UIControlEventTouchUpInside)];
    [setAliasBtn setTitle:@"设置别名" forState:(UIControlStateNormal)];
    [setAliasBtn setBackgroundColor:UIColor.grayColor];
    [self.view addSubview:setAliasBtn];
    
    
    UIButton *deleteAliasBtn = [[UIButton alloc] initWithFrame:(CGRectMake((UIScreen.mainScreen.bounds.size.width - 200)/2, 200, 200, 50))];
    [deleteAliasBtn addTarget:self action:@selector(deleteAliasAction) forControlEvents:(UIControlEventTouchUpInside)];
    [deleteAliasBtn setTitle:@"删除别名" forState:(UIControlStateNormal)];
    [deleteAliasBtn setBackgroundColor:UIColor.grayColor];
    [self.view addSubview:deleteAliasBtn];
    
}


- (void)setAliasAction {
    [MOPushClient setAlias:@"123123" deleteOtherDevices:YES completion:^(MOPushResponse *response) {
            
        if (response.isSuccess) {
            NSLog(@"-------------------------- 设置别名成功 --------------------------");
        } else {
            NSLog(@"-------------------------- 设置别名失败：%@ --------------------------", response.msg);
        }
    }];
}


- (void)deleteAliasAction {
    
    [MOPushClient deleteAliasWithOption:(MOPushDeleteAliasOptionAll) completion:^(MOPushResponse *response) {
        
        if (response.isSuccess) {
            NSLog(@"-------------------------- 删除别名成功 --------------------------");
        } else {
            NSLog(@"-------------------------- 删除别名失败：%@ --------------------------", response.msg);
        }
    }];
}


@end
